package com.mebs.edi.model.edi.e211;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.mebs.edi.model.dom.DomAttribute;
import com.mebs.edi.model.dom.DomEntity;
import com.mebs.model.inventory.OrderItem;
import com.mebs.model.inventory.PurchaseOrder;

/**
 * 
 * AT subsection (representing Purchase Order and Order Item) of ST section in a 211 EDI file 
 * 
 * @author nit
 *
 */
@Entity()
@Table(name = "edi_211_at")
@DomEntity(name = "AT", discriminatorAttribute = "AT101")
public class Edi211At {
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "Id")
	private Long id;

	@Column(nullable = true)
	@DomAttribute
	private Integer at101; 		// Lading Line Item Number
	
	@Column(nullable = true, length = 1000)
	@DomAttribute
	private String at401; 		// Lading Description
	
	@Column(nullable = true)
	@DomAttribute
	private Integer at201; 		// Lading Quantity
	
	@Column(nullable = true, length = 3)
	@DomAttribute
	private String at202; 		// Packaging Form Code
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String at203; 		// Weight Qualifier
	
	@Column(nullable = true)
	@DomAttribute
	private Character at204; 	// Weight Unit Code
	
	@Column(nullable = true)
	@DomAttribute
	private Float at205; 		// Weight
	
	@Column(nullable = true)
	@DomAttribute
	private Integer at206; 		// Lading Quantity
	
	@Column(nullable = true, length = 3)
	@DomAttribute
	private String at207; 		// Packaging Form Code

	@Column(nullable = true)
	@DomAttribute
	private Character at208; 	// Yes/No Condition or Response Code
	
	@Column(nullable = true, length = 16)
	@DomAttribute
	private String at209; 		// Commodity Code
	
	@Column(nullable = true, length = 5)
	@DomAttribute
	private String at210; 		// Freight Class Code

	@ManyToOne(optional = false)
    @JoinColumn(name = "commodity_id")
	private OrderItem orderItem;
	
	@Column(nullable = true, length = 22)
	@DomAttribute
	private String spo01; 		// Purchase Order Number
	
	@Column(nullable = true, length = 22)
	@DomAttribute
	private String spo02; 		// Reference Identification
	
	@Column(nullable = true, length = 2)
	@DomAttribute
	private String spo03; 		// Unit or basis for Measurement Code
	
	@Column(nullable = true)
	@DomAttribute
	private Long spo04; 		// Quantity
	
	@Column(nullable = true)
	@DomAttribute
	private Character spo05; 	// Weight Unit Code
	
	@Column(nullable = true)
	@DomAttribute
	private Float spo06; 		// Weight
	
	@Column(nullable = true, length = 3)
	@DomAttribute
	private String spo07; 		// Application Error Condition Code
	
	@Column(nullable = true, length = 30)
	@DomAttribute
	private String spo08; 		// Reference Identification
	
	@ManyToOne(optional = false)
    @JoinColumn(name = "purchase_order_id")
	private PurchaseOrder purchaseOrder;
	
	public Edi211At() {
		super();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getAt101() {
		return at101;
	}

	public void setAt101(Integer at101) {
		this.at101 = at101;
	}

	public String getAt401() {
		return at401;
	}

	public void setAt401(String at401) {
		this.at401 = at401;
	}

	public Integer getAt201() {
		return at201;
	}

	public void setAt201(Integer at201) {
		this.at201 = at201;
	}

	public String getAt202() {
		return at202;
	}

	public void setAt202(String at202) {
		this.at202 = at202;
	}

	public String getAt203() {
		return at203;
	}

	public void setAt203(String at203) {
		this.at203 = at203;
	}

	public Character getAt204() {
		return at204;
	}

	public void setAt204(Character at204) {
		this.at204 = at204;
	}

	public Float getAt205() {
		return at205;
	}

	public void setAt205(Float at205) {
		this.at205 = at205;
	}

	public Integer getAt206() {
		return at206;
	}

	public void setAt206(Integer at206) {
		this.at206 = at206;
	}

	public String getAt207() {
		return at207;
	}

	public void setAt207(String at207) {
		this.at207 = at207;
	}

	public Character getAt208() {
		return at208;
	}

	public void setAt208(Character at208) {
		this.at208 = at208;
	}

	public String getAt209() {
		return at209;
	}

	public void setAt209(String at209) {
		this.at209 = at209;
	}

	public String getAt210() {
		return at210;
	}

	public void setAt210(String at210) {
		this.at210 = at210;
	}
	
	public OrderItem getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(OrderItem orderItem) {
		this.orderItem = orderItem;
	}

	public String getSpo01() {
		return spo01;
	}

	public void setSpo01(String spo01) {
		this.spo01 = spo01;
	}

	public String getSpo02() {
		return spo02;
	}

	public void setSpo02(String spo02) {
		this.spo02 = spo02;
	}

	public String getSpo03() {
		return spo03;
	}

	public void setSpo03(String spo03) {
		this.spo03 = spo03;
	}

	public Long getSpo04() {
		return spo04;
	}

	public void setSpo04(Long spo04) {
		this.spo04 = spo04;
	}

	public Character getSpo05() {
		return spo05;
	}

	public void setSpo05(Character spo05) {
		this.spo05 = spo05;
	}

	public Float getSpo06() {
		return spo06;
	}

	public void setSpo06(Float spo06) {
		this.spo06 = spo06;
	}

	public String getSpo07() {
		return spo07;
	}

	public void setSpo07(String spo07) {
		this.spo07 = spo07;
	}

	public String getSpo08() {
		return spo08;
	}

	public void setSpo08(String spo08) {
		this.spo08 = spo08;
	}
	
	public PurchaseOrder getPurchaseOrder() {
		return purchaseOrder;
	}

	public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
		this.purchaseOrder = purchaseOrder;
	}

	@Override
	public String toString() {
		return "Edi211At [id=" + id + ", at101=" + at101 + ", at401=" + at401 + ", at201=" + at201
				+ ", at202=" + at202 + ", at203=" + at203 + ", at204=" + at204 + ", at205=" + at205
				+ ", at206=" + at206 + ", at207=" + at207 + ", at208=" + at208 + ", at209=" + at209
				+ ", at210=" + at210 + ", spo01=" + spo01 + ", spo02=" + spo02 + ", spo03=" + spo03
				+ ", spo04=" + spo04 + ", spo05=" + spo05 + ", spo06=" + spo06 + ", spo07=" + spo07
				+ ", spo08=" + spo08 + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((at101 == null) ? 0 : at101.hashCode());
		result = prime * result + ((at201 == null) ? 0 : at201.hashCode());
		result = prime * result + ((at202 == null) ? 0 : at202.hashCode());
		result = prime * result + ((at203 == null) ? 0 : at203.hashCode());
		result = prime * result + ((at204 == null) ? 0 : at204.hashCode());
		result = prime * result + ((at205 == null) ? 0 : at205.hashCode());
		result = prime * result + ((at206 == null) ? 0 : at206.hashCode());
		result = prime * result + ((at207 == null) ? 0 : at207.hashCode());
		result = prime * result + ((at208 == null) ? 0 : at208.hashCode());
		result = prime * result + ((at209 == null) ? 0 : at209.hashCode());
		result = prime * result + ((at210 == null) ? 0 : at210.hashCode());
		result = prime * result + ((at401 == null) ? 0 : at401.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((spo01 == null) ? 0 : spo01.hashCode());
		result = prime * result + ((spo02 == null) ? 0 : spo02.hashCode());
		result = prime * result + ((spo03 == null) ? 0 : spo03.hashCode());
		result = prime * result + ((spo04 == null) ? 0 : spo04.hashCode());
		result = prime * result + ((spo05 == null) ? 0 : spo05.hashCode());
		result = prime * result + ((spo06 == null) ? 0 : spo06.hashCode());
		result = prime * result + ((spo07 == null) ? 0 : spo07.hashCode());
		result = prime * result + ((spo08 == null) ? 0 : spo08.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Edi211At other = (Edi211At) obj;
		if (at101 == null) {
			if (other.at101 != null)
				return false;
		} else if (!at101.equals(other.at101))
			return false;
		if (at201 == null) {
			if (other.at201 != null)
				return false;
		} else if (!at201.equals(other.at201))
			return false;
		if (at202 == null) {
			if (other.at202 != null)
				return false;
		} else if (!at202.equals(other.at202))
			return false;
		if (at203 == null) {
			if (other.at203 != null)
				return false;
		} else if (!at203.equals(other.at203))
			return false;
		if (at204 == null) {
			if (other.at204 != null)
				return false;
		} else if (!at204.equals(other.at204))
			return false;
		if (at205 == null) {
			if (other.at205 != null)
				return false;
		} else if (!at205.equals(other.at205))
			return false;
		if (at206 == null) {
			if (other.at206 != null)
				return false;
		} else if (!at206.equals(other.at206))
			return false;
		if (at207 == null) {
			if (other.at207 != null)
				return false;
		} else if (!at207.equals(other.at207))
			return false;
		if (at208 == null) {
			if (other.at208 != null)
				return false;
		} else if (!at208.equals(other.at208))
			return false;
		if (at209 == null) {
			if (other.at209 != null)
				return false;
		} else if (!at209.equals(other.at209))
			return false;
		if (at210 == null) {
			if (other.at210 != null)
				return false;
		} else if (!at210.equals(other.at210))
			return false;
		if (at401 == null) {
			if (other.at401 != null)
				return false;
		} else if (!at401.equals(other.at401))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (spo01 == null) {
			if (other.spo01 != null)
				return false;
		} else if (!spo01.equals(other.spo01))
			return false;
		if (spo02 == null) {
			if (other.spo02 != null)
				return false;
		} else if (!spo02.equals(other.spo02))
			return false;
		if (spo03 == null) {
			if (other.spo03 != null)
				return false;
		} else if (!spo03.equals(other.spo03))
			return false;
		if (spo04 == null) {
			if (other.spo04 != null)
				return false;
		} else if (!spo04.equals(other.spo04))
			return false;
		if (spo05 == null) {
			if (other.spo05 != null)
				return false;
		} else if (!spo05.equals(other.spo05))
			return false;
		if (spo06 == null) {
			if (other.spo06 != null)
				return false;
		} else if (!spo06.equals(other.spo06))
			return false;
		if (spo07 == null) {
			if (other.spo07 != null)
				return false;
		} else if (!spo07.equals(other.spo07))
			return false;
		if (spo08 == null) {
			if (other.spo08 != null)
				return false;
		} else if (!spo08.equals(other.spo08))
			return false;
		return true;
	}
}
